/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2021/6/20
 * Time: 22:36
 */

#ifndef CODSEEGMENT_PNGDAOWIDGET_H
#define CODSEEGMENT_PNGDAOWIDGET_H

#include <QtSql>
#include <QtWidgets>

#define RES_DB_FILE_PATH QCoreApplication::applicationDirPath() + "/../../../res/res.db"

class PngDaoWidget
    : public QWidget
{
    Q_OBJECT

public:
    explicit PngDaoWidget(QWidget * parent = nullptr);

    ~PngDaoWidget() override;

private:
    void InitWidgets();

    void InitUi();
    void InitDB();

    void InitEvent();

    void InsertPng(const QString & file_name);
    void InsertPng(const QStringList & file_names);
    void InsertPng(const QDir& dir);
    void RemovePng(const QString & png_name);
    QPixmap GetPng(const QString & png_name);
private:
    QSqlDatabase                 database_obj_;
    QLineEdit *                  lineEdit_;
    QPushButton *                pushButton_;
    QLabel *                     png_label_;
    QTableView *                 tableView_;
    QButtonGroup *               buttonGroup_;
    QMap<QString, QPushButton *> btn_map_;
};

#endif//CODSEEGMENT_PNGDAOWIDGET_H
